var myApp = angular.module('myApp', ['ui.router', 'treeGrid'])
    .controller('indexCtrl', ['$rootScope', '$scope', '$log', function ($rootScope, $scope, $log) {
        console.log($location.search())
    }])
    .run(['$rootScope','localdb', function ($rootScope,localdb) {
        $rootScope.url = config.backend_url;
        $rootScope.userId = localdb.get('userId','');
        $rootScope.accessToken = localdb.get('accessToken','');
        console.log($rootScope.userId);
        console.log($rootScope.accessToken);
    }])
    .config(['$logProvider', function ($logProvider) {
        //true开启 false关闭    <debug>
        $logProvider.debugEnabled(true);
    }])
    .config(function($httpProvider){
        //开启http header中的authorization
        $httpProvider.interceptors.push('tokenInterceptor');
    })
    .config(function ($stateProvider, $urlRouterProvider, $locationProvider) {
        $locationProvider.hashPrefix('');//解决#！
        //解决路由异常的方法
        $urlRouterProvider.otherwise('dashboard');
        $stateProvider
            .state('order/index', {
                url: '/order/index',
                templateUrl: 'order/order-index.html'

            })
            .state('account/index', {
                url: '/account/index',
                templateUrl: 'account/account-index.html'

            })
            .state('obd/index', {
                url: '/obd/index',
                templateUrl: 'obd/obd-index.html'

            })
            .state('command/dtc', {
                url: '/command/dtc',
                templateUrl: 'command/command-dtc.html'

            })
            .state('command/model', {
                url: '/command/model',
                templateUrl: 'command/command-model.html'

            })
            .state('dashboard', {
                url: '/dashboard',
                templateUrl: 'dashboard/dashboard.html'
            })
    });
